﻿@model SiteCredivale.ViewModels.avisoViewModel

@{
  
    Layout = "~/Areas/Intranet/Views/Shared/_Layout2.cshtml";
       
}
 


<script type="text/javascript" src="~/Areas/Intranet/ckeditor/ckeditor.js"></script>


<div id="topico" name="topico" class="topico">Aviso</div>
<div class="box_medio">

      
                                                             
 @using (Html.BeginForm(null, null, FormMethod.Post, new { @id = "form" }))
                    {
     
     
       
      @Html.ValidationSummary(true)
                        
     
       
                             <div class="editor-field">
                            <label class="txtLabel">
                               Enviar por :</label>
                                
                                           <select id="tipo" name="tipo" >
                                   <option value="sel" selected>[selecione]</option>
                                <option value="set">Setor</option>
                                <option value="uni">Unidade</option>
                            </select>
                               @Html.ValidationMessageFor(model => model.tipo)
                            </div>
                       
     
     
      <fieldset id="quadrochk" name="quadrochk" class="seguros"><legend class="editor-field">
                             <label class="txtLabel">
                                tipo:</label>
                           </legend>
                          

                        <div id="listadechk" name="listadechk">
                     

                 </div>
                              
                           
                           </fieldset>
     
     <br />
     <div class="editor-field">
                            <label class="txtLabel">
                               descricao:</label>
                                
                                            @Html.TextAreaFor(model => model.aviso_descricao,new {@class="ckeditor" })
                                           @Html.ValidationMessageFor(model => model.aviso_descricao)
                                             
                            </div>
             <br /> 
               
     
     
     <input id="Salvar" type="submit" value="Salvar" class="btn" />
                  
}


       @if (ViewBag.res != null)
      { 
        
           
  @Html.Raw("<script type='text/javascript'>successAlert('Sucesso', '" + ViewBag.res + "');</script>")
   
         
}
    @if (ViewBag.err != null)
    {


        @Html.Raw("<script type='text/javascript'>errorsAlert('Atenção', '" + ViewBag.err + "');</script>")


    }

    <script>


    



        function marcardesmarcar() {
          

            if ($("#todos").is(':checked')) {
                //$("input[type=checkbox]").prop('checked', true); //todos los check
                $("#listadechk input[type=checkbox]").prop('checked', true); //solo los del objeto #diasHabilitados
            } else {
                //$("input[type=checkbox]").prop('checked', false);//todos los check
                $("#listadechk input[type=checkbox]").prop('checked', false);//solo los del objeto #diasHabilitados
            }
        }




        $().ready(function () {

       
      


            $("#quadrochk").slideUp();


          


            $("#tipo").bind("change", function () {


                if ($("#tipo").val() != 'sel') {

                    $("#quadrochk").slideDown();
                    $("#listadechk").empty();
                    $.getJSON("GetTipo", { tipo: $("#tipo").val() }, function (result) {


                        data = $.parseJSON(result);
                        $("#listadechk").append("<br /><input id='todos' name='todos' value='-1' onclick='marcardesmarcar();' type='checkbox'>  Todos<br />");
                  

                        for (var i = 0; i < data.length; i++) {

                            var item = data[i];
                            //$('<input />', { type: 'checkbox', id: 'tipos',name:'tipos', value: item.desc}).appendTo('#listadechk');

                            $("#listadechk").append("<input id='tipos' name='tipos' class='marcar' value='" + item.id + "' type='checkbox'/>  " + item.desc + "<br />");
                            //$("#listadechk").append(input);
                        }
                     
                      

                    });

                }
                else
                    $("#quadrochk").slideUp();
            });





        });




          </script>

    



    </div>

 